import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/components/Layout'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: 'homePage',
    component: Layout,
    children: [
      {
        path: 'homePage',
        name: 'homePage',
        component: () => import('@/views/homePage'),
        meta: {
          title: '首页'
        }
      },
      {
        path: 'userPage',
        name: 'userPage',
        component: () => import('@/views/userPage'),
        meta: {
          title: '用户中心'
        }
      },
      {
        path: 'blogUpload',
        name: 'blogUpload',
        component: () => import('@/views/blogUpload'),
        meta: {
          title: '博客上传页面'
        }
      }
    ]
  },
  {
    path: '/loginPage',
    name: 'loginPage',
    component: () => import('@/views/loginPage')
  },
  {
    path: '/registerPage',
    name: 'registerPage',
    component: () => import('@/views/registerPage')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
